import Vue from 'vue'
import Router from 'vue-router'

//路由重定向
const routerRedirect = process.env.VUE_APP_ROUTER_REDIRECT || "/workorder";

Vue.use(Router)
export const constantRoutes = [
  {
    path: '/',
    redirect: routerRedirect
  },
  {
    path:'/workorder',
    name:'workorder',
    component:() => import('@/views/workorder/index2.vue')
  },
  {
    path:'/workorder2',
    name:'workorder2',
    component:() => import('@/views/workorder/index3.vue')
  },
  {
    path:'/workorder3',
    name:'workorder3',
    component:() => import('@/views/workorder/tableCopy.vue')
  },
  {
    path:"/workorder4",
    name:"workorder4",
    component:() => import('@/views/workorder/productionWarehousing.vue')
  },
  {
    path:"/workorder4/detail", //入库审核详情
    name:"workorder4Detail",
    component:() => import("@/views/workorder/productionWarehousing_detail.vue")
  },
  {
    path:"/workorder5",
    name:"workorder5",
    component:() => import("@/views/workorder/supplementaryWarehouseing.vue")
  },
  {
    path:"/workorder6",
    name:"workorder6",
    component:() => import("@/views/workorder/oeeStatement.vue")
  },
  {
    path:"/workorder7",
    name:"MachineMonthReport",
    component:() => import("@/views/workorder/machineMonthReport.vue")
  },
  {
    path:"/workorder8",
    name:"MeterTable",
    component:() => import("@/views/workorder/meterTable.vue")
  },
  {
    path:"/workorder9",
    name:"WarehouseEntry",
    component:() => import("@/views/workorder/warehouseEntry.vue")
  },
  {
    path:"/warehouseEntry",
    name:"WarehouseEntry",
    component:() => import("@/views/warehouseEntry/index.vue")
  }, 
  {
    path:"/materialTable",
    name:"MaterialTable",
    component:() => import("@/pages/materialTable/index.vue")
  },
  {
    path:"/rowMaterialTable",
    name:"RowMatrialTable",
    component:() => import("@/pages/rowMaterialTable/index.vue")
  },
  {
    path:"/machineHalt",
    name:"MachineHaltReport",
    component:() => import("@/pages/machineHaltReport/index.vue")
  },
  {
    path:"/monthlyCostSummary",
    name:"MonthlyCostSummary",
    component:() => import("@/pages/monthlyCostSummary/index.vue")
  },
  {
    path:"/workorder10",
    name:"ProjectMonthReport",
    component:() => import("@/views/workorder/projectMonthReport.vue")
  },
  {
    path:"/workorder11",
    name:"SummarySheet",
    component:() => import("@/views/workorder/summarySheet.vue")
  },
  {
    path:"/classAdjust",
    name:"ClassAdjust",
    component:() => import("@/pages/classAdjust/index.vue")
  },
  {
    path:"/proMaterialReq",  //简单生产领料单
    name:"ProductionMaterialRequest",
    component:() => import("@/pages/productionMaterialRequest/index.vue")
  },
  {
    path:"/proMaterialReq/detail", //简单生产领料单详情
    name:"ProMaterialReqDetail",
    component:() => import("@/pages/productionMaterialRequest/detail.vue")
  },
  {
    path:"/proMaterialRet",  //简单生产退料单
    name:"ProductionMaterialReturn",
    component:() => import("@/pages/productionMaterialReturn/index.vue")
  },
  {
    path:"/proMaterialRet/detail", //简单生产退料单详情
    name:"ProMaterialRetDetail",
    component:() => import("@/pages/productionMaterialReturn/detail.vue")
  },
  {
    path:"/proMaterialRetSto",  //生产退库单
    name:"ProductionMaterialReturnToStock",
    component:() => import("@/pages/productionMaterialReturnToStock/index.vue")
  },
  {
    path:"/proMaterialRetSto/detail",  //生产退库单详情
    name:"ProMaterialRetStoDetail",
    component:() => import("@/pages/productionMaterialReturnToStock/detail.vue")
  },
  {
    path:"/proInbound",   //简单生产入库
    name:"ProductionInbound",
    component:() => import("@/pages/productionInbound/index.vue"),
  },
  {
    path:"/proInbound/detail",  //简单生产入库详情
    name:"ProInboundDetail",
    component:() => import("@/pages/productionInbound/detail.vue")
  },
  {
    path:"/proRetInve",  //简单生产退库
    name:"ProductionReturnInventory",
    component:() => import("@/pages/productionReturnInventory/index.vue")
  },
  {
    path:"/proRetInve/detail",  //简单生产退库详情
    name:"ProRetInveDetail",
    component:() => import("@/pages/productionReturnInventory/detail.vue")
  },
  {
    path:"/batNumAdjForm",  //批号调整单
    name:"BatchNumberAdjustmentForm",
    component:() => import("@/pages/batchNumberAdjustmentForm/index.vue")
  },
  {
    path:"/batNumAdjForm/detail",  //批号调整单详情
    name:"BatchNumberAdjustmentFormDetail",
    component:() => import("@/pages/batchNumberAdjustmentForm/detail.vue")
  },
  {
    path:"/purchaseInventoryApproveProcess",  //采购入库审批流程
    name:"PurchaseInventoryApproveProcess",
    component: () => import("@/views/purchaseInventoryApproveProcess/index.vue")
  },
  {
    path:"/purchaseInventoryApproveProcess/update",
    name:"PurchaseInventoryApproveProcessUpdate",
    component: () => import("@/views/purchaseInventoryApproveProcess/components/update.vue")
  },
  {
    path:"/approvalTask",  //采购审批任务列表
    name:"ApprovalTask",
    component: () => import("@/views/approvalTask/index.vue")
  },
  {
    path:"/workHourAllocation",  //工时分摊
    name:"WorkHourAllocation",
    component: () => import("@/views/workHourAllocation/index.vue")
  },
  {
    path:"/workHourAllocation/add",  //工时分摊新增
    name:"WorkHourAllocationAdd",
    component: () => import("@/views/workHourAllocation/add.vue")
  },
  {
    path:"/purchasingDemand",  //采购需求二开
    name:"PurchasingDemand",
    component: () => import("@/views/purchasing-demand/index.vue")
  },
  {
    path:"/purchasingDemand/update",  //采购需求二开
    name:"PurchasingDemandUpdate",
    component: () => import("@/views/purchasing-demand/update.vue")
  },
  {
    path:"/statement",
    name:"statement",
    component: () => import("@/views/statement/index.vue")
  },
  {
    path:"/inspection",
    name:"inspection",
    component: () => import("@/views/inspectionDataEntering/index.vue")
  },
  {
    path:"/reportform",
    name:"reportform",
    component: () => import("@/views/reportForms/index.vue")
  },
  {
    path:"/statistics",
    name:"statistics",
    component: () => import("@/views/statistics/index.vue")
  },
  {
    path:"/staffquestionnaire",
    name:"staffquestionnaire",
    component: () => import("@/views/staffInspectionQuestionnaire/index.vue")
  },
  {
    path:"/questionnaire",
    name:"questionnaire",
    component: () => import("@/views/processInspectionQuestionnaire/index.vue")
  },  
  {
    path:"/projectquality",
    name:"projectquality",
    component: () => import("@/views/projectQualityInspectionReportForms/index.vue")
  },
  // {
  //   path:"/reportformOfStaff",
  //   name:"projectquality",
  //   component: () => import("@/views/projectQualityInspectionReportForms/index.vue")
  // },
  //other pages
  //test pages
]

const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

// 路由守卫 判断是否登录了
router.beforeEach((to, from, next) => {
  next()
})

export default router
